Error: The RStudio 'Plots' window is too small to show this set of plots. You may try one of the
following steps to resolve this problem.
- To fix this issue, please make the window larger.
- If this doesn't help, try to reset your zoom settings. In RStudio, go to Menu "View >
Actual Size" and then retry.
- If this still doesn't resolve your problems, you may check whether your apps are rescaled.
On Windows, this can be done in the display settings (Start > Settings > System > Display,
"Scale and layout"). Reduce the scaling and try again.
- Finally, you can try to decrease the base font-size of your theme before plotting. Load
`library(ggplot2)` and run: `theme_set(theme_classic(base_size = 6))`
| Metric | Value |
|---|---|
| AIC | 9.12e+05 |
| AICc | 9.12e+05 |
| BIC | 9.12e+05 |
| R2 | 0.92 |
| R2 (adj.) | 0.92 |
| RMSE | 1129.84 |
| Sigma | 1130.09 |
For interpretation of performance metrics, please refer to this documentation.
| Parameter | Coefficient | SE | 95% CI | t(53916) | p |
|---|---|---|---|---|---|
| (Intercept) | 5753.76 | 396.63 | (4976.36, 6531.16) | 14.51 | < .001 |
| carat | 11256.98 | 48.63 | (11161.67, 11352.29) | 231.49 | < .001 |
| cut (linear) | 584.46 | 22.48 | (540.40, 628.51) | 26.00 | < .001 |
| cut (quadratic) | -301.91 | 17.99 | (-337.18, -266.64) | -16.78 | < .001 |
| cut (cubic) | 148.03 | 15.48 | (117.69, 178.38) | 9.56 | < .001 |
| cut (4th degree) | -20.79 | 12.38 | (-45.05, 3.46) | -1.68 | 0.093 |
| color (linear) | -1952.16 | 17.34 | (-1986.15, -1918.17) | -112.57 | < .001 |
| color (quadratic) | -672.05 | 15.78 | (-702.98, -641.13) | -42.60 | < .001 |
| color (cubic) | -165.28 | 14.72 | (-194.14, -136.42) | -11.22 | < .001 |
| color (4th degree) | 38.20 | 13.53 | (11.68, 64.71) | 2.82 | 0.005 |
| color (5th degree) | -95.79 | 12.78 | (-120.83, -70.75) | -7.50 | < .001 |
| color (6th degree) | -48.47 | 11.61 | (-71.23, -25.70) | -4.17 | < .001 |
| clarity (linear) | 4097.43 | 30.26 | (4038.12, 4156.74) | 135.41 | < .001 |
| clarity (quadratic) | -1925.00 | 28.23 | (-1980.33, -1869.68) | -68.20 | < .001 |
| clarity (cubic) | 982.20 | 24.15 | (934.87, 1029.54) | 40.67 | < .001 |
| clarity (4th degree) | -364.92 | 19.29 | (-402.72, -327.12) | -18.92 | < .001 |
| clarity (5th degree) | 233.56 | 15.75 | (202.69, 264.44) | 14.83 | < .001 |
| clarity (6th degree) | 6.88 | 13.72 | (-20.00, 33.77) | 0.50 | 0.616 |
| clarity (7th degree) | 90.64 | 12.10 | (66.92, 114.36) | 7.49 | < .001 |
| depth | -63.81 | 4.53 | (-72.69, -54.92) | -14.07 | < .001 |
| table | -26.47 | 2.91 | (-32.18, -20.77) | -9.09 | < .001 |
| x | -1008.26 | 32.90 | (-1072.74, -943.78) | -30.65 | < .001 |
| y | 9.61 | 19.33 | (-28.28, 47.50) | 0.50 | 0.619 |
| z | -50.12 | 33.49 | (-115.75, 15.51) | -1.50 | 0.134 |
To find out more about table summary options, please refer to this documentation.
Error in Ops.data.frame(guide_loc, panel_loc): '==' only defined for equally-sized data frames
| carat | Predicted | SE | 95% CI |
|---|---|---|---|
| -1.10 | -21538.74 | 106.13 | (-21746.75, -21330.73) |
| -0.62 | -16202.81 | 86.54 | (-16372.43, -16033.18) |
| -0.15 | -10866.87 | 69.13 | (-11002.37, -10731.37) |
| 0.32 | -5530.94 | 55.96 | ( -5640.62, -5421.26) |
| 0.80 | -195.01 | 50.46 | ( -293.91, -96.10) |
| 1.27 | 5140.93 | 54.99 | ( 5033.15, 5248.70) |
| 1.75 | 10476.86 | 67.55 | ( 10344.46, 10609.27) |
| 2.22 | 15812.80 | 84.65 | ( 15646.88, 15978.72) |
| 2.69 | 21148.73 | 104.07 | ( 20944.75, 21352.72) |
| 3.17 | 26484.67 | 124.74 | ( 26240.18, 26729.15) |
Variable predicted: price
Predictors modulated: carat
Predictors controlled: cut (1), color (1), clarity (1), depth (62), table (57), x (5.7), y (5.7), z (3.5)
| cut | Predicted | SE | 95% CI |
|---|---|---|---|
| Fair | -195.01 | 50.46 | (-293.91, -96.10) |
| Good | 384.75 | 47.28 | ( 292.07, 477.42) |
| Very Good | 531.78 | 45.79 | ( 442.03, 621.53) |
| Premium | 567.14 | 45.51 | ( 477.93, 656.34) |
| Ideal | 637.91 | 45.31 | ( 549.10, 726.71) |
Variable predicted: price
Predictors modulated: cut
Predictors controlled: carat (0.8), color (1), clarity (1), depth (62), table (57), x (5.7), y (5.7), z (3.5)
| color | Predicted | SE | 95% CI |
|---|---|---|---|
| D | -195.01 | 50.46 | ( -293.91, -96.10) |
| E | -404.12 | 49.75 | ( -501.63, -306.62) |
| F | -467.86 | 49.59 | ( -565.05, -370.67) |
| G | -677.04 | 49.64 | ( -774.34, -579.75) |
| H | -1175.27 | 49.98 | (-1273.23, -1077.32) |
| I | -1661.25 | 51.17 | (-1761.55, -1560.95) |
| J | -2564.40 | 53.43 | (-2669.13, -2459.67) |
Variable predicted: price
Predictors modulated: color
Predictors controlled: carat (0.8), cut (1), clarity (1), depth (62), table (57), x (5.7), y (5.7), z (3.5)
| clarity | Predicted | SE | 95% CI |
|---|---|---|---|
| I1 | -195.01 | 50.46 | (-293.91, -96.10) |
| SI2 | 2507.58 | 34.78 | (2439.42, 2575.74) |
| SI1 | 3470.47 | 34.60 | (3402.65, 3538.29) |
| VS2 | 4072.22 | 34.94 | (4003.73, 4140.70) |
| VS1 | 4383.39 | 35.93 | (4312.96, 4453.82) |
| VVS2 | 4755.81 | 37.37 | (4682.56, 4829.06) |
| VVS1 | 4812.75 | 39.18 | (4735.96, 4889.55) |
| IF | 5150.10 | 43.70 | (5064.44, 5235.75) |
Variable predicted: price
Predictors modulated: clarity
Predictors controlled: carat (0.8), cut (1), color (1), depth (62), table (57), x (5.7), y (5.7), z (3.5)
| depth | Predicted | SE | 95% CI |
|---|---|---|---|
| 56.02 | 170.63 | 61.45 | ( 50.19, 291.08) |
| 57.45 | 79.22 | 57.81 | ( -34.09, 192.54) |
| 58.88 | -12.19 | 54.70 | (-119.40, 95.03) |
| 60.32 | -103.60 | 52.22 | (-205.95, -1.24) |
| 61.75 | -195.01 | 50.46 | (-293.91, -96.10) |
| 63.18 | -286.42 | 49.49 | (-383.43, -189.41) |
| 64.61 | -377.83 | 49.37 | (-474.60, -281.05) |
| 66.05 | -469.24 | 50.10 | (-567.43, -371.04) |
| 67.48 | -560.65 | 51.64 | (-661.86, -459.43) |
| 68.91 | -652.06 | 53.92 | (-757.75, -546.36) |
Variable predicted: price
Predictors modulated: depth
Predictors controlled: carat (0.8), cut (1), color (1), clarity (1), table (57), x (5.7), y (5.7), z (3.5)
| table | Predicted | SE | 95% CI |
|---|---|---|---|
| 48.52 | 41.62 | 60.57 | ( -77.10, 160.34) |
| 50.75 | -17.54 | 57.11 | (-129.46, 94.39) |
| 52.99 | -76.69 | 54.20 | (-182.93, 29.55) |
| 55.22 | -135.85 | 51.96 | (-237.69, -34.01) |
| 57.46 | -195.01 | 50.46 | (-293.91, -96.10) |
| 59.69 | -254.16 | 49.77 | (-351.72, -156.61) |
| 61.93 | -313.32 | 49.93 | (-411.18, -215.45) |
| 64.16 | -372.47 | 50.92 | (-472.29, -272.66) |
| 66.40 | -431.63 | 52.71 | (-534.94, -328.32) |
| 68.63 | -490.79 | 55.21 | (-599.00, -382.58) |
Variable predicted: price
Predictors modulated: table
Predictors controlled: carat (0.8), cut (1), color (1), clarity (1), depth (62), x (5.7), y (5.7), z (3.5)
| x | Predicted | SE | 95% CI |
|---|---|---|---|
| 1.24 | 4329.11 | 156.84 | ( 4021.70, 4636.51) |
| 2.37 | 3198.08 | 122.47 | ( 2958.03, 3438.12) |
| 3.49 | 2067.05 | 90.14 | ( 1890.38, 2243.72) |
| 4.61 | 936.02 | 63.04 | ( 812.47, 1059.57) |
| 5.73 | -195.01 | 50.46 | ( -293.91, -96.10) |
| 6.85 | -1326.03 | 61.99 | (-1447.53, -1204.53) |
| 7.97 | -2457.06 | 88.67 | (-2630.86, -2283.26) |
| 9.10 | -3588.09 | 120.86 | (-3824.97, -3351.21) |
| 10.22 | -4719.12 | 155.16 | (-5023.23, -4415.01) |
| 11.34 | -5850.14 | 190.43 | (-6223.40, -5476.89) |
Variable predicted: price
Predictors modulated: x
Predictors controlled: carat (0.8), cut (1), color (1), clarity (1), depth (62), table (57), y (5.7), z (3.5)
| y | Predicted | SE | 95% CI |
|---|---|---|---|
| 1.17 | -238.90 | 100.51 | (-435.91, -41.89) |
| 2.31 | -227.93 | 82.17 | (-388.97, -66.88) |
| 3.45 | -216.95 | 66.14 | (-346.59, -87.32) |
| 4.59 | -205.98 | 54.52 | (-312.85, -99.11) |
| 5.73 | -195.01 | 50.46 | (-293.91, -96.10) |
| 6.88 | -184.03 | 55.63 | (-293.07, -74.99) |
| 8.02 | -173.06 | 67.96 | (-306.26, -39.85) |
| 9.16 | -162.08 | 84.36 | (-327.44, 3.27) |
| 10.30 | -151.11 | 102.91 | (-352.82, 50.61) |
| 11.45 | -140.13 | 122.64 | (-380.51, 100.24) |
Variable predicted: price
Predictors modulated: y
Predictors controlled: carat (0.8), cut (1), color (1), clarity (1), depth (62), table (57), x (5.7), z (3.5)
| z | Predicted | SE | 95% CI |
|---|---|---|---|
| 0.72 | -53.53 | 106.75 | (-262.75, 155.69) |
| 1.42 | -88.90 | 86.64 | (-258.72, 80.93) |
| 2.13 | -124.27 | 68.82 | (-259.16, 10.63) |
| 2.83 | -159.64 | 55.53 | (-268.47, -50.81) |
| 3.54 | -195.01 | 50.46 | (-293.91, -96.10) |
| 4.24 | -230.37 | 55.91 | (-339.96, -120.78) |
| 4.95 | -265.74 | 69.45 | (-401.86, -129.62) |
| 5.66 | -301.11 | 87.39 | (-472.40, -129.83) |
| 6.36 | -336.48 | 107.55 | (-547.29, -125.68) |
| 7.07 | -371.85 | 128.90 | (-624.49, -119.20) |
Variable predicted: price
Predictors modulated: z
Predictors controlled: carat (0.8), cut (1), color (1), clarity (1), depth (62), table (57), x (5.7), y (5.7)
We fitted a linear model (estimated using OLS) to predict price with carat, cut, color, clarity, depth, table, x, y and z (formula: price ~ carat + cut + color + clarity + depth + table + x + y + z). The model explains a statistically significant and substantial proportion of variance (R2 = 0.92, F(23, 53916) = 26881.83, p < .001, adj. R2 = 0.92). The model’s intercept, corresponding to carat = 0, cut = , color = , clarity = , depth = 0, table = 0, x = 0, y = 0 and z = 0, is at 5753.76 (95% CI (4976.36, 6531.16), t(53916) = 14.51, p < .001). Within this model:
Standardized parameters were obtained by fitting the model on a standardized version of the dataset. 95% Confidence Intervals (CIs) and p-values were computed using a Wald t-distribution approximation. The model explains a statistically significant and substantial proportion of variance (R2 = 0.92, F(23, 53916) = 26881.83, p < .001, adj. R2 = 0.92)
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, : arguments imply differing number of rows: 1, 0
List of 48
$ is_binomial : logi FALSE
$ is_bernoulli : logi FALSE
$ is_count : logi FALSE
$ is_poisson : logi FALSE
$ is_negbin : logi FALSE
$ is_beta : logi FALSE
$ is_betabinomial : logi FALSE
$ is_orderedbeta : logi FALSE
$ is_dirichlet : logi FALSE
$ is_exponential : logi FALSE
$ is_logit : logi FALSE
$ is_probit : logi FALSE
$ is_censored : logi FALSE
$ is_truncated : logi FALSE
$ is_survival : logi FALSE
$ is_linear : logi TRUE
$ is_tweedie : logi FALSE
$ is_zeroinf : logi FALSE
$ is_zero_inflated: logi FALSE
$ is_dispersion : logi FALSE
$ is_hurdle : logi FALSE
$ is_ordinal : logi FALSE
$ is_cumulative : logi FALSE
$ is_multinomial : logi FALSE
$ is_categorical : logi FALSE
$ is_mixed : logi FALSE
$ is_multivariate : logi FALSE
$ is_trial : logi FALSE
$ is_bayesian : logi FALSE
$ is_gam : logi FALSE
$ is_anova : logi FALSE
$ is_timeseries : logi FALSE
$ is_ttest : logi FALSE
$ is_correlation : logi FALSE
$ is_onewaytest : logi FALSE
$ is_chi2test : logi FALSE
$ is_ranktest : logi FALSE
$ is_levenetest : logi FALSE
$ is_variancetest : logi FALSE
$ is_xtab : logi FALSE
$ is_proptest : logi FALSE
$ is_binomtest : logi FALSE
$ is_ftest : logi FALSE
$ is_meta : logi FALSE
$ link_function : chr "identity"
$ family : chr "gaussian"
$ n_obs : int 53940
$ n_grouplevels : NULL
Error in DT::datatable(model_info_data): 'data' must be 2-dimensional (e.g. data frame or matrix)
---
title: "Regression model summary from `{easystats}`"
output:
flexdashboard::flex_dashboard:
theme:
version: 4
# bg: "#101010"
# fg: "#FDF7F7"
primary: "#0054AD"
base_font:
google: Prompt
code_font:
google: JetBrains Mono
params:
model: model
check_model_args: check_model_args
parameters_args: parameters_args
performance_args: performance_args
---
```{r setup, include=FALSE}
library(flexdashboard)
library(easystats)
# Since not all regression model are supported across all packages, make the
# dashboard chunks more fault-tolerant. E.g. a model might be supported in
# `{parameters}`, but not in `{report}`.
#
# For this reason, `error = TRUE`
knitr::opts_chunk$set(
error = TRUE,
out.width = "100%"
)
# helper function for printing `{report}` outputs
bracket_to_parantheses <- function(text) {
gsub("]", ")", gsub("[", "(", text, fixed = TRUE), fixed = TRUE)
}
```
```{r easydashboard-1}
# Get user-specified model data
model <- params$model
# Is it supported by `{easystats}`? Skip evaluation of the following chunks if not.
is_supported <- insight::is_model_supported(model)
if (!is_supported) {
unsupported_message <- sprintf(
"Unfortunately, objects of class `%s` are not yet supported in {easystats}.\n
For a list of supported models, see `insight::supported_models()`.",
class(model)[1]
)
}
```
Model fit
=====================================
Column {data-width=700}
-----------------------------------------------------------------------
### Assumption checks
```{r check-model, eval=is_supported, fig.height=10, fig.width=10}
check_model_args <- c(list(model), params$check_model_args)
# add verbose, if not done yet
if (is.null(check_model_args$verbose)) check_model_args$verbose <- FALSE
tryCatch(
{
do.call(performance::check_model, check_model_args)
},
error = function(e) {
cat(insight::format_message(
"\nSomething did not work as expected. Please file an issue at {.url https://github.com/easystats/easystats/issues/} and post the following output:",
paste0("\n`", e$message, "`")
))
}
)
```
```{r easydashboard-2, eval=!is_supported}
cat(unsupported_message)
```
Column {data-width=300}
-----------------------------------------------------------------------
### Indices of model fit
```{r easydashboard-3, eval=is_supported}
# {performance}
performance_args <- c(list(model), params$performance_args)
# add verbose, if not done yet
if (is.null(performance_args$verbose)) performance_args$verbose <- FALSE
table_performance <- do.call(performance::performance, performance_args)
print_md(table_performance, layout = "vertical", caption = NULL)
```
```{r easydashboard-4, eval=!is_supported}
cat(unsupported_message)
```
For interpretation of performance metrics, please refer to <a href="https://easystats.github.io/performance/reference/model_performance.html" target="_blank">this documentation</a>.
Parameter estimates
=====================================
Column {data-width=550}
-----------------------------------------------------------------------
### Plot
```{r dot-whisker, eval=is_supported}
# `{parameters}`
parameters_args <- c(list(model), params$parameters_args)
# add verbose, if not done yet
if (is.null(parameters_args$verbose)) parameters_args$verbose <- FALSE
table_parameters <- do.call(parameters::parameters, parameters_args)
plot(table_parameters)
```
```{r easydashboard-5, eval=!is_supported}
cat(unsupported_message)
```
Column {data-width=450}
-----------------------------------------------------------------------
### Tabular summary
```{r easydashboard-6, eval=is_supported}
print_md(table_parameters, caption = NULL)
```
```{r easydashboard-7, eval=!is_supported}
cat(unsupported_message)
```
To find out more about table summary options, please refer to <a href="https://easystats.github.io/parameters/reference/model_parameters.html" target="_blank">this documentation</a>.
Predicted Values
=====================================
Column {data-width=600}
-----------------------------------------------------------------------
### Plot
```{r expected-values, eval=is_supported, fig.height=10, fig.width=10}
# {modelbased}
int_terms <- find_interactions(model, component = "conditional", flatten = TRUE)
con_terms <- find_variables(model)$conditional
if (is.null(int_terms)) {
model_terms <- con_terms
} else {
model_terms <- clean_names(int_terms)
int_terms <- unique(unlist(strsplit(clean_names(int_terms), ":", fixed = TRUE)))
model_terms <- c(model_terms, setdiff(con_terms, int_terms))
}
# check some exceptions here: logistic regression models with factor response
# usually require the response to be included in the model, else `get_modelmatrix()`
# fails, which is required to compute SE/CI for `get_predicted()`
response <- find_response(model)
minfo <- model_info(model)
model_data <- get_data(model)
include_response <- minfo$is_binomial && minfo$is_logit && is.factor(model_data[[response]])
text_modelbased <- tryCatch(
{
lapply(unique(model_terms), function(i) {
grid <- get_datagrid(
model,
at = i,
range = "grid",
preserve_range = FALSE,
verbose = FALSE,
include_response = include_response
)
estimate_expectation(model, data = grid, verbose = FALSE)
})
},
error = function(e) {
cat(insight::format_message(
"\nSomething did not work as expected. Please file an issue at {.url https://github.com/easystats/easystats/issues/} and post the following output:",
paste0("\n`", e$message, "`")
))
NULL
}
)
if (!is.null(text_modelbased)) {
ggplot2::theme_set(theme_modern())
# all_plots <- lapply(text_modelbased, function(i) {
# out <- do.call(visualisation_recipe, c(list(i), modelbased_args))
# plot(out) + ggplot2::ggtitle("")
# })
all_plots <- lapply(text_modelbased, function(i) {
out <- visualisation_recipe(i, show_data = "none")
plot(out) + ggplot2::ggtitle("")
})
see::plots(all_plots, n_columns = round(sqrt(length(text_modelbased))))
}
```
```{r easydashboard-8, eval=!is_supported}
cat(unsupported_message)
```
Column {data-width=400}
-----------------------------------------------------------------------
### Tabular summary
```{r easydashboard-9, eval=is_supported, results="asis"}
if (!is.null(text_modelbased)) {
for (i in text_modelbased) {
tmp <- print_md(i)
tmp <- gsub("Variable predicted", "\nVariable predicted", tmp, fixed = TRUE)
tmp <- gsub("Predictors modulated", "\nPredictors modulated", tmp, fixed = TRUE)
tmp <- gsub("Predictors controlled", "\nPredictors controlled", tmp, fixed = TRUE)
print(tmp)
}
}
```
```{r easydashboard-10, eval=!is_supported}
cat(unsupported_message)
```
Text reports
=====================================
Column {data-width=500}
-----------------------------------------------------------------------
### Textual summary
```{r easydashboard-11, eval=is_supported, results='asis', collapse=TRUE}
# {report}
text_report <- tryCatch(
{
report(model, verbose = FALSE)
},
error = function(e) {
cat(insight::format_message(
"\nSomething did not work as expected. Please file an issue at {.url https://github.com/easystats/easystats/issues/} and post the following output:",
paste0("\n`", e$message, "`")
))
NULL
}
)
text_report_performance <- tryCatch(
{
report_performance(model, verbose = FALSE)
},
error = function(e) {
cat(insight::format_message(
"\nSomething did not work as expected. Please file an issue at {.url https://github.com/easystats/easystats/issues/} and post the following output:",
paste0("\n`", e$message, "`")
))
NULL
}
)
if (!is.null(text_report)) {
cat(bracket_to_parantheses(text_report))
cat("\n")
}
if (!is.null(text_report_performance)) {
cat(bracket_to_parantheses(text_report_performance))
}
```
```{r easydashboard-12, eval=!is_supported}
cat(unsupported_message)
```
Column {data-width=500}
-----------------------------------------------------------------------
### Model information
```{r easydashboard-13, eval=is_supported}
model_info_data <- insight::model_info(model, verbose = FALSE)
model_info_data <- datawizard::data_to_long(as.data.frame(model_info_data))
DT::datatable(model_info_data)
```
```{r easydashboard-14, eval=!is_supported}
cat(unsupported_message)
```